-- Options are automatically loaded before lazy.nvim startup
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here

-- LazyVim picker to use.
-- Can be one of: telescope, fzf
-- Leave it to "auto" to automatically use the picker
-- enabled with `:LazyExtras`
vim.g.lazyvim_picker = "fzf"

-- Enable LazyVim auto format
vim.g.autoformat = false

-- LazyVim root dir detection
-- Each entry can be:
-- * the name of a detector function like `lsp` or `cwd`
-- * a pattern or array of patterns like `.git` or `lua`.
-- * a function with signature `function(buf) -> string|string[]`
vim.g.root_spec = {
	"lsp",
	{
		".git",
		".gitignore",
		"go.mod",
		"src",
		"README.md",
		"Jenkinsfile*",
		"topology.yml",
		"topology.yaml",
		-- "build.sh",
		-- ".bashrc",
	},
	"cwd",
}

vim.g.deprecation_warnings = false

vim.g.trouble_lualine = false

local opt = vim.opt

opt.textwidth = 88
opt.autowrite = false -- Enable auto write
-- opt.clipboard = "unnamedplus"  -- Sync with system clipboard
-- opt.conceallevel = 3           -- Hide * markup for bold and italic
-- opt.confirm = true             -- Confirm to save changes before exiting modified buffer
-- opt.grepformat = "%f:%l:%c:%m"
-- opt.list = true            -- Show some invisible characters (tabs...
-- opt.mouse = "a"            -- Enable mouse mode
-- opt.number = true          -- Print line number
-- opt.relativenumber = true  -- Relative line numbers
opt.showmode = false -- Dont show mode since we have a statusline
opt.sidescrolloff = 2 -- Columns of context
opt.scrolloff = 0 -- Lines of context
-- opt.spelllang = { "en" }
-- opt.splitkeep = "screen"
opt.undofile = true
opt.undolevels = 10000
opt.wildmode = "longest:full,full" -- Command-line completion mode
opt.completeopt = "menu,menuone,noinsert,noselect"
opt.cursorline = true -- Enable highlighting of the current line
opt.expandtab = true -- Use spaces instead of tabs
opt.formatoptions = "jcroqlnt" -- tcqj
opt.grepprg = "rg --vimgrep"
opt.ignorecase = true -- Ignore case
opt.inccommand = "nosplit" -- preview incremental substitute
opt.laststatus = 3 -- global statusline
opt.pumblend = 10 -- Popup blend
opt.pumheight = 25 -- Maximum number of entries in a popup
opt.sessionoptions = { "buffers", "tabpages", "winsize", "winpos", "globals", "skiprtp", "folds" }
opt.shiftround = true -- Round indent
opt.shiftwidth = 2 -- Size of an indent
opt.shortmess:append({ W = true, I = true, c = true, C = true })
opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
opt.smartcase = true -- Don't ignore case with capitals
opt.smartindent = true -- Insert indents automatically
opt.splitbelow = true -- Put new windows below current
opt.splitright = true -- Put new windows right of current
opt.tabstop = 2 -- Number of spaces tabs count for
opt.termguicolors = true -- True color support
opt.timeoutlen = 600
opt.updatetime = 200 -- Save swap file and trigger CursorHold
opt.virtualedit = "block,insert" -- Allow cursor to move where there is no text in visual block mode
opt.ruler = false
opt.fillchars = {
	foldopen = "",
	foldclose = "",
	-- fold = "⸱",
	fold = " ",
	foldsep = " ",
	diff = "╱",
	eob = " ",
}
opt.winminwidth = 10 -- Minimum window width
opt.wrap = false -- Disable line wrap

-- Commands mode
opt.wildmenu = true -- on TAB, complete options for system command
opt.wildignore =
	"deps,.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,.DS_Store,*.aux,*.out,*.toc"
-- " set wildignore=*.o,*.obj,*~,*.exe,*.a,*.pdb,*.lib
-- " set wildignore+=*.so,*.dll,*.swp,*.egg,*.jar,*.class,*.pyc,*.pyo,*.bin,*.dex
-- " set wildignore+=*.log,*.pyc,*.sqlite,*.sqlite3,*.min.js,*.min.css,*.tags
-- " set wildignore+=*.zip,*.7z,*.rar,*.gz,*.tar,*.gzip,*.bz2,*.tgz,*.xz
-- " set wildignore+=*.png,*.jpg,*.gif,*.bmp,*.tga,*.pcx,*.ppm,*.img,*.iso
-- " set wildignore+=*.pdf,*.dmg,*.app,*.ipa,*.apk,*.mobi,*.epub
-- " set wildignore+=*.mp4,*.avi,*.flv,*.mov,*.mkv,*.swf,*.swc
-- " set wildignore+=*.ppt,*.pptx,*.doc,*.docx,*.xlt,*.xls,*.xlsx,*.odt,*.wps
-- " set wildignore+=*/.git/*,*/.svn/*,*.DS_Store
-- " set wildignore+=*/node_modules/*,*/nginx_runtime/*,*/build/*,*/logs/*,*/dist/*,*/tmp/*

-- vim.opt.matchtime = 2 -- delay before showing matching paren
vim.opt.mps = vim.o.mps .. ",<:>"

-- if vim.fn.has("nvim-0.10") == 1 then
--   opt.smoothscroll = true
--   opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()"
--   opt.foldmethod = "expr"
-- -- opt.foldtext = ""
-- else
--   opt.foldmethod = "indent"
--   opt.foldtext = "v:lua.require'lazyvim.util'.ui.foldtext()"
-- end
-- opt.foldtext = "v:lua.require'lazyvim.util'.ui.foldtext()"

-- Fix markdown indentation settings
vim.g.markdown_recommended_style = 0

-- !!! seadog
-- opt.redrawtime = 3000
-- opt.noswapfile = true
-- opt.noshowcmd = true
-- opt.incsearch = true
-- opt.noshowmode = true
-- opt.nobackup = true
-- opt.title = true
-- opt.nonumber = true
-- opt.norelativenumber = true
-- opt.hlsearch = true
-- opt.autoindent = true
-- opt.autoread = true
-- opt.nowrap = true
-- opt.hidden = true
-- opt.noerrorbells = true
opt.guicursor = "n-v-c:block,i-ci-ve:ver25,a:blinkwait700-blinkoff400-blinkon250-Cursor"
-- set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50,a:blinkwait500-blinkoff300-blinkon200-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175

-- !!! override
opt.number = false -- Print line number
opt.relativenumber = false -- Relative line numbers
opt.list = false -- Show some invisible characters (tabs...
opt.mouse = "" -- Enable mouse mode
vim.g.ai_cmp = true
-- vim.g.mapleader = ","
-- vim.g.maplocalleader = "q"
-- opt.statuscolumn = [[%!v:lua.require'snacks.statuscolumn'.get()]]
